<?php
class Category
{
	public function construct()
	{
		
	}
	
	public function index()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile("model/Category.php");
		$smarty = new Smarty();
		$modCat = new ModelCategory();
		$smarty->debugging = false;
		$smarty->caching = false;
		$smarty->cache_lifetime = 120;
		
		$smarty->assign("title", "Category Management");
		
		$parent_cat_arr = $modCat->getParentCat();
		$cat_arr = $modCat->listCategories();
		$smarty->assign("parent_cat_arr", $parent_cat_arr);
		$smarty->assign("cat_arr", $cat_arr);
		$smarty->display('category/index.tpl');
	}
	
	public function renameCategory()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile("model/Category.php");
		$smarty = new Smarty();
		$modCat = new ModelCategory();
		$request = CommonFunc::getRequest();
		$catid = $request['catid'];
		$catlabel = $request['category'];
		$modCat->renameCat($catid, $catlabel);		
	}
}	
?>